﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace TimeStart
{
    public partial class Report : Form
    {
        public Report()
        {
            InitializeComponent();
        }

        private void Report_Load(object sender, EventArgs e)
        {
            this.Text = Home.tmex[28];
            DirectoryInfo folder = new DirectoryInfo("RECORDS");
            FileInfo[] txtfiles = folder.GetFiles("*.txt");
            foreach (FileInfo finfo in txtfiles)
            {
                listBox.Items.Add(finfo.Name);
            }
        }

        private void listBox_Click(object sender, EventArgs e)
        {
            try
            {
                TextReader showreport = new StreamReader("RECORDS\\" + listBox.SelectedItem);
                treport.Text = showreport.ReadToEnd();
                showreport.Close();
            }
            catch (Exception ex)
            {
                treport.Text = ex.Data.ToString();
            }

        }

        private void Report_FormClosed(object sender, FormClosedEventArgs e)
        {
            Home.reportshown = false;
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
